package com.cn.qtms.vo;//类注释设置模板

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * @Name:SecWeeksVo 时间星期计算vo类
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-12-26 16:16
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SecWeeksVo {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long actId;

    private List<String> weekDays;

    /**
     * 将weeks转成String字符串，中间用,隔开
     *
     * @param weeks
     * @return
     */
    public String getWeeksString(List<String> weeks) {
        String result = null;
        if (weeks.size() > 0) {
            StringBuilder builder = new StringBuilder();
            weeks.forEach(item -> {
                builder.append(item + ",");
            });
            result = StringUtils.substringBeforeLast(builder.toString(), ",");
        }
        return result;
    }
}
